home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / AboutBoxƒ / CPPYentaAboutBox.cp next >
Encoding:
Text File  |  1996-04-04  |  2.6 KB  |  106 lines  |  [TEXT/KAHL]

  1. /***************************************************** IMPLEMENTATION
  2.     DATE:    10/21/93
  3.     AUTHOR: Eric R. Rosé
  4.  
  5.     CLASS:  CPPYentaAboutBox
  6.     
  7.     SUPERCLASS: CPPWindow
  8.     
  9.         This C++ class manages the Yenta about box dialog
  10.     
  11. ********************************************************************/
  12.  
  13. #include "CPPYentaAboutBox.h"
  14. #include <CPPWindowManager.h>
  15. #include <CPPButton.h>
  16. #include <CPPStaticText.h>
  17. #include <ToolboxTools.h>
  18.  
  19. #define    prefsWindowID    202
  20.  
  21. extern    CPPWindowManager    *gWindowManager;
  22. extern    void DoStdOKButton (CPPWindow *theWindow);
  23. extern    void DoStdCancelButton (CPPWindow *theWindow);
  24.  
  25. Rect    AboutRect = {42,20, 158, 262};
  26.  
  27. /*-----------------------------------------------------------------*/
  28. /*------------------------ PUBLIC METHODS -------------------------*/
  29. /*-----------------------------------------------------------------*/
  30.                           
  31.     CPPYentaAboutBox::CPPYentaAboutBox (CPPWindowManager *theManager) :
  32.                       CPPWindow (theManager, &AboutRect, "\pAbout", TRUE,
  33.                                    altDBoxProc, FALSE, 13, TRUE, FALSE, systemFont, 12)
  34.     {
  35.         GrafPtr    SavePort;
  36.         Rect    tempRect;
  37.         
  38.         GetPort(&SavePort);
  39.         SetPort(this->theWindow);
  40.         
  41.     //    create static text item
  42.         SetRect (&tempRect, 10, 10, 232, 65);
  43.         aboutText = new CPPStaticText ((CPPWindow *)this, &tempRect, 
  44.             "\pYenta v1.0\rwritten by Eric Rosé\rusing the Appletalk Class Library", 
  45.             systemFont, 12, teJustCenter);
  46.  
  47.     // create the dialog buttons
  48.         SetRect (&tempRect, 79, 84, 159, 104);
  49.         okButton = new CPPButton ((CPPWindow *)this, &tempRect, "\pOK", TRUE);
  50.         okButton->SetDoClickProc (DoStdOKButton);
  51.         
  52.         SetPort(SavePort);
  53.     }
  54.     
  55. /*-----------------------------------------------------------------*/
  56.  
  57.     CPPYentaAboutBox::~CPPYentaAboutBox ()
  58.     {
  59.         
  60.     }
  61.  
  62. /*-----------------------------------------------------------------*/
  63.  
  64.     char    *CPPYentaAboutBox::ClassName (void)
  65.     {
  66.         return "CPPPrefsWindow";
  67.     }
  68.     
  69. /*-----------------------------------------------------------------*/
  70.  
  71.     Boolean    CPPYentaAboutBox::DoUserKey (EventRecord *theEvent)
  72.     {
  73.         char theKey;
  74.         CPPList    *TempList;
  75.  
  76.         theKey = theEvent->message & charCodeMask;
  77.           switch (theKey) {
  78.               case kEnter :
  79.               case kReturn :
  80.                   if (okButton)
  81.                     okButton->SimulateClick();
  82.               default:
  83.                   return TRUE;
  84.                   break;
  85.         } // switch
  86.  
  87.     }
  88.  
  89. /*-----------------------------------------------------------------*/
  90.     
  91.     Boolean    DoAboutBox (void)
  92.     {
  93.         CPPYentaAboutBox    *theWindow;
  94.         Boolean            theResult;
  95.         
  96.         theWindow = new CPPYentaAboutBox (gWindowManager);
  97.           
  98.         if (theWindow)
  99.           {
  100.               theWindow->DoModalWindow ();
  101.               delete theWindow;
  102.               return theResult;
  103.           }
  104.         else
  105.           SysBeep(1);
  106.     }